<?php
session_start();
include('functions.php');
//echo session_id();
db();
//global variables $o = outword
$o['root'] = 'http://dev.outword.org';
$o['images'] = $o['root'].'/images/';
?>
<?php include('url_parser.php'); 
$thisroot = $o['root'].'/'.$site['siteurl'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
	<title><?php echo $site['name'] ?></title>
	<style>
		<?php include('css.php'); ?>
	</style>	
	<style>
		<?php include('js/datepicker/style.php'); ?>
	</style>	
	<script type="text/javascript" src="<?php echo $o['root']; ?>/js/jquery/jquery-1.3.2.min.js"></script>
	<script type="text/javascript" src="<?php echo $o['root']; ?>/js/datepicker/datepicker.js"></script>
	<!---<script type="text/javascript" src="<?php echo $o['root']; ?>/js/curvycorners.js"></script>--->
	<script>
	/***JQUERY*****************************************/
	$(document).ready(function(){
		$('input').attr('autocomplete','off');
		ajaxCalendar(<?php echo date('m'); ?>,<?php echo date('Y'); ?>);
		$('span#add').click(function(){
		var relvalue = $(this).attr('rel');
			$('#postid').attr('value','add');
			$('#addtype').attr('value',relvalue);
			//alert($('#postid').attr('value'));
			$('#postform').submit();
		});
		$('span#edit').click(function(){
		var relvalue2 = $(this).attr('rel');
			$('#postid').attr('value',relvalue2);
			$('#addtype').attr('value','');
			//alert($('#postid').attr('value'));
			$('#postform').submit();
		});
		$('#event_isonsite').change(function(){
			var thisvalue = $(this).attr('value');
			if(thisvalue == 0){$('#eventaddr').show();}else{$('#eventaddr').hide();}
		});
		$('#cc_isonsite').change(function(){
			var thisvalue = $(this).attr('value');
			if(thisvalue == 0){$('#ccaddr').show();}else{$('#ccaddr').hide();}
		});
		$('#event_ischildcare').change(function(){
			var thisvalue = $(this).attr('value');
			if(thisvalue == 1){$('#childcare_post').show();}else{$('#childcare_post').hide();}
		});
	});
	

	/******************************************************/
	function ajaxCalendar(m,y){
		var month = m;
		var year = y;
		$("#ajaxcalendarinner").load("<?php echo $o['root']; ?>/ajax/calendar.php",{m: month,y: year,siteid: <?php echo $site['id']; ?>,root: '<?php echo $o['root']; ?>',thisroot: '<?php echo $thisroot; ?>'});
	}
	function chxSearchType(elid){
		$('.searchtype').removeClass('current');
		$('#'+elid).addClass('current');
		document.s.searchtype.value = elid;
	}
	function editContent(item){
		document.editform.edititem.value=item;
		document.editform.submit();
	}					
	</script>
	<?php if($_SESSION['access'] && in_array(1,$_SESSION['access'])){ ?>
			<script type="text/javascript" src="<?php echo $o['root']; ?>/js/tiny_mce/tiny_mce.js"></script>
			<script type="text/javascript">
				tinyMCE.init({
				mode: "textareas", theme: "advanced", skin : "o2k7",
				/* skin_variant : "silver", */
				plugins : "safari,paste,spellchecker,iespell",
				theme_advanced_toolbar_location : "top",
				theme_advanced_buttons1 :"bold,italic,underline,|,bullist,numlist,|,outdent,indent,|,link,unlink,|,pasteword,|,spellchecker",
				theme_advanced_buttons2 : "", theme_advanced_buttons3 : "",	editor_selector : "mceEditor",	width: '590', height:'200'
				});
			</script> 
			<script type="text/javascript">
				function toggleEditor(id) {
					if (!tinyMCE.get(id))
						tinyMCE.execCommand('mceAddControl', false, id);
					else
						tinyMCE.execCommand('mceRemoveControl', false, id);
				}			
			</script>
	<?php	} ?>
</head>
<body>
<div id="test"></div>
<div id="wrap">
	<div id="sites">
		<?php 
		if($_SESSION && in_array(1,$_SESSION['access'])){
			$isadmin = 1;
			/* sites */
			include('sites.php');
		} ?>
	</div>
	<div id="loginnav">
		<?php if($_SESSION['loggedinuserid']){ ?>
			<a class="loginlink" href="<?php echo $thisroot; ?>/profile.php"><?php echo $_SESSION['username']; ?></a> <span class="loginlink">|</span> <a class="loginlink" href="<?php echo $thisroot; ?>/logout.php">Logout</a>
		<?php }else{ ?>
			<a class="loginlink" href="<?php echo $thisroot; ?>/register.php">Register</a> <span class="loginlink">|</span> <a class="loginlink" href="<?php echo $thisroot; ?>/login.php">Login</a>
		<?php } ?>
	</div>
	<div class="clear"></div>
	<div id="page">
		<!--header-->
		<div id="header">
			<div id="member">
				<h1 id="member_name"><span onclick="window.location.href='<?php echo $thisroot; ?>';"><?php echo $site['name'] ?></span><?php if($_SESSION['access'] && in_array(1,$_SESSION['access'])){editHeaderLink('name');} ?></h1>
				<h2 id="member_tagline"><?php echo $site['tagline'] ?><?php if($_SESSION['access'] && in_array(1,$_SESSION['access'])){editHeaderLink('tagline');} ?></h2>
				<!---
				<div id="membernav">
					<a href="<?php echo $thisroot; ?>" class="membernavlink">home</a>
					<a href="<?php echo $thisroot; ?>/money.php" class="membernavlink">donate</a>
				</div>
				--->
			</div>
			<div id="outword">
				<span style="cursor: pointer;" onclick="window.location.href='<?php echo $o['root']; ?>';"><img src="<?php echo $o['images'].'outwordlogo-sm.png'; ?>" /></span>
				<h2 id="outword_tagline">start stuff. get the word out.</h2>
				<!---
				<div id="outwordnav">
					<a href="<?php echo $o['root']; ?>" class="membernavlink">home</a>
					<a href="<?php echo $o['root'].'/outword/blog.php'; ?>" class="membernavlink">blog</a>
					<a href="<?php echo $o['root'].'/outword/money.php'; ?>" class="membernavlink">donate</a>
				</div>
				--->
			</div>
			
		</div><!--/header-->
		<div class="clear"></div>